using System;
using AndyPike.Commons.Persistence.NHibernate;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;

namespace AndyPike.Commons.Tests.Unit.Persistence.NHibernate
{
    [TestFixture]
    public class When_deciding_if_a_web_request_requires_a_nhibernate_session
    {
        [Test]
        public void Should_return_true_for_urls_ending_in_rails()
        {
            ISpecification<Uri> spec = new NHibernateWebSessionRequiredSpecification();
            bool answer = spec.IsSatisfiedBy(new Uri("http://localhost/controller/action.rails"));

            Assert.That(answer, Is.True);
        }

        [Test]
        public void Should_return_false_for_any_other_type_of_request()
        {
            ISpecification<Uri> spec = new NHibernateWebSessionRequiredSpecification();
            bool answer = spec.IsSatisfiedBy(new Uri("http://localhost/images/logo.gif"));

            Assert.That(answer, Is.False);
        }
    }
}